package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Category;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DishMapper {

    @Select("SELECT count(id) FROM  dish WHERE category_id=#{categoryId}")
    Integer countByCategoryId(long categoryId);

    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    Page<DishVO> page(DishPageQueryDTO dishPageQueryDTO);

    List<Dish> selectByIds(@Param("Ids") List<Long> Ids);

    void delByIds(@Param("Ids") List<Long> Ids);

    @Select("SELECT  * FROM dish WHERE id=#{id}")
    Dish queryById(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void updateWithFlavor(Dish dish);

    @Select("SELECT * FROM dish WHERE id=#{id}")
    Dish queryByIdz(long id);
}
